package model

import (
	"gorm.io/gorm"
	"time"
)

type Video struct {
	gorm.Model
	UserId    int    `gorm:"type:int(11)"`
	ClassId   int    `gorm:"type:int(11)"`
	Vip       int    `gorm:"type:int(1)"`
	Url       string `gorm:"type:varchar(500)"`
	ImageUrl  string `gorm:"type:varchar(500)"`
	ShowCount int    `gorm:"type:int(11)"`
	Title     string `gorm:"type:varchar(100)"`
	Len       int    `gorm:"type:int(11)"`
	Status    int    `gorm:"type:int(1)"`
}
type VideoVipGet struct {
	Vid         int
	Uid         int
	Vip         int
	LoginStatus int
	VipEnd      time.Time
}

func (v *VideoVipGet) UseVipShow() (string, bool) {
	var video Video
	DB.Where("id = ?", v.Vid).Find(&video)
	if video.Vip == 1 {
		return "非会员视频", true
	} else {
		if v.Vip == 1 {
			return "会员等级不足", false
		}
		if v.VipEnd.Unix()-time.Now().Unix() < 0 {
			return "会员过期", false
		}
		return "", true
	}
}
